package pageShare

import (
	"net/http"

	"laundry-service/app/client/internal/logic/pageShare"
	"laundry-service/app/client/internal/svc"
	"laundry-service/app/client/internal/types"
	"laundry-service/common"

	"github.com/zeromicro/go-zero/rest/httpx"
)

func GetPageShareListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req types.Request
		if err := httpx.Parse(r, &req); err != nil {
			httpx.ErrorCtx(r.Context(), w, common.NewErrResponse(http.StatusBadRequest, err.Error()))
			return
		}

		l := pageShare.NewGetPageShareListLogic(r.Context(), svcCtx)
		resp, err := l.GetPageShareList(&req)
		if err != nil {
			httpx.ErrorCtx(r.Context(), w, common.NewErrResponse(http.StatusInternalServerError, err.Error()))
		} else {
			httpx.OkJsonCtx(r.Context(), w, common.NewSuccessResponse(resp))
		}
	}
}
